#include "framepolaroidplugin.h"

class FramePolaroidPlugin;

K_PLUGIN_FACTORY( KDCMenuPluginFactory, registerPlugin< FramePolaroidPlugin >(); )
K_EXPORT_PLUGIN( KDCMenuPluginFactory( "FramePolaroidPlugin" ) )

#include "framepolaroidjob.h"

#include <interfaces/kdcapplicationinterface.h>
KDCApplicationInterface *gAppInterface;

FramePolaroidPlugin::FramePolaroidPlugin( QObject *parent, const QVariantList &args ) : FramePluginInterface( parent ), pInfo( KPluginInfo("framepolaroidplugin.desktop", "services") )
{
	Q_UNUSED( args )
	gAppInterface = NULL;
}

FramePolaroidPlugin::~FramePolaroidPlugin()
{

}

const KPluginInfo& FramePolaroidPlugin::info() const
{
	return pInfo;
}

QPixmap FramePolaroidPlugin::preview() const
{
	QString path;
	if ( gAppInterface )
		path = gAppInterface->applicationDataDir() + "/frames/frame_polaroid_thumb.png";
	return QPixmap( path );
}

QPixmap FramePolaroidPlugin::create( const QPixmap &aInput, int aWidth, int aHeight, QString &aError ) const
{
	FramePolaroidJob job( aInput );
	if ( job.exec() )
		return job.resultFrame();
	aError = job.errorText();
	return QPixmap();
}

KDCFrameJobInterface* FramePolaroidPlugin::createJob( const QPixmap &aInput, int aWidth, int aHeight ) const
{
	return new FramePolaroidJob( aInput );
}


void FramePolaroidPlugin::setApplicationInterface( KDCApplicationInterface* aInterface )
{
	gAppInterface = aInterface;
}

